﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Cosmetic.Logic;

namespace WebApp.Controls
{
    public partial class AttentionProduct2 : System.Web.UI.UserControl
    {
        private ProductManager m_ProductManager = new ProductManager();
        int count = 0;
        int showcount;

        public int ShowCount
        {
            get { return showcount; }
            set { showcount = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            count = 1;
            this.BindProduct();
        }

        private void BindProduct()
        {
            //本月热销
            this.lvProduct.DataSource = m_ProductManager.GetCurrentMonthFocusProductInfo(count).ToList();
            this.lvProduct.DataBind();
            //本周热销
            this.ListView1.DataSource = m_ProductManager.GetCurrentWeekFocusProductInfo(count).ToList();
            this.ListView1.DataBind();
            //关注排行
            this.ListView2.DataSource = this.m_ProductManager.GetFocusProductInfo(9).ToList();
            this.ListView2.DataBind();
        }
        protected void lvProduct_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            //if (count != 1)
            //{
            //    Image ig = e.Item.FindControl("Img1") as Image;
            //    ig.ImageUrl = Cosmetic.WebGeneric.SmallImage(ig.ImageUrl);
            //    ig.Height = Convert.ToInt32(ig.Height.Value / 2);
            //    ig.Width = Convert.ToInt32(ig.Width.Value / 2);
            //}
            //int i;
            //HtmlImage img = e.Item.FindControl("img") as HtmlImage;

            //if (img != null)
            //{
            //    i = Convert.ToInt16(e.Item.ClientID.Substring(e.Item.ClientID.Length - 7, 1)) * 3 + Convert.ToInt16(e.Item.ClientID.Substring(e.Item.ClientID.Length - 2)) + 1;
            //    if (i < 10)
            //    {
            //        img.Src = "../imagesWeb/Hot0" + i.ToString() + ".gif";
            //    }
            //    else
            //    {
            //        img.Src = "../imagesWeb/Hot" + i.ToString() + ".gif";
            //    }
            //}
            //count++;
        }

    }
}